package com.gljx.web.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gljx.web.Entity.CoaceGroup;
import com.gljx.web.dao.CoaceGroupMapper;
import com.gljx.web.dao.CommonDao;
import com.gljx.web.service.CoaceGroupService;

@Service
@Transactional
public class CoaceGroupServiceImpl extends CommonDao implements CoaceGroupService{

	@Autowired
	private CoaceGroupMapper coaceGroupMapper;
	
	/**
	 *取分页数据    dmz 20160921
	 *@param pindex 页码
	 *@param psql SQL语句，需要带 rownum rn 例如：select rownum rn,t.* from zzda t
	 *@param psize 每页记录数
	 * */
	@Override
	public Map<String, Object> selectPage(int pindex, String psql, int psize) {
		  Map<String, Object> paramMap = new HashMap<String, Object>();
	       paramMap.put("Pindex", pindex);
	       paramMap.put("Psql", psql);
	       paramMap.put("Psize", psize);
	       paramMap.put("Pcount", oracle.jdbc.OracleTypes.INTEGER);
	       paramMap.put("v_cur", oracle.jdbc.OracleTypes.CURSOR);
	       this.getSqlSession().select("com.gljx.web.dao.CoaceGroupMapper.pagemap", paramMap, null);
	       return  paramMap;
	}

	/**
	 * 取记录总数      dmz 20160921
	 * @param psql   SQL语句
	 * @param Pcount 记录总数
	 * @return
	 */
	@Override
	public Map<String, Object> selectPageCount(String psql) {
		   Map<String, Object> paramMap = new HashMap<String, Object>();
	       paramMap.put("Psql", psql);
	       paramMap.put("Pcount", oracle.jdbc.OracleTypes.INTEGER);
	       this.getSqlSession().select("com.gljx.web.dao.CoaceGroupMapper.pagecount", paramMap, null);
	       return paramMap;
	}

	/**
	 * 实现根据名称查询
	 */
	@Override
	public List<CoaceGroup> queryCoaceGroupByFnameL2(String companyId,String fnameL2) {
		// TODO Auto-generated method stub
		Map<String, String> map =new HashMap<>();
		map.put("companyId", companyId);
		map.put("fnameL2", fnameL2);
		return coaceGroupMapper.selectCoaceGroupByFnameL2(map);
	}

	/**
	 * 实现添加
	 */
	@Override
	public void addCoaceGroup(CoaceGroup coaceGroup) {
		// TODO Auto-generated method stub
		coaceGroupMapper.insertSelective(coaceGroup);
	}

	/**
	 * 实现删除
	 */
	@Override
	public void deleteCoaceGroupByFid(String fid) {
		// TODO Auto-generated method stub
		coaceGroupMapper.deleteByPrimaryKey(fid);
	}

	/**
	 * 实现根据fid查询
	 */
	@Override
	public CoaceGroup queryCoaceGroupByFid(String fid) {
		// TODO Auto-generated method stub
		return coaceGroupMapper.selectCoaceGroupByFid(fid);
	}

	/**
	 * 实现修改
	 */
	@Override
	public void modifyCoaceGroup(CoaceGroup coaceGroup) {
		// TODO Auto-generated method stub
		coaceGroupMapper.updateByPrimaryKeySelective(coaceGroup);
	}

    @Override
    public List<CoaceGroup> selectCoaceGroupByInfo(String fcompanyid, String fnameL2) {
        Map<String, String> map = new HashMap<>();
        map.put("fcompanyid", fcompanyid);
        map.put("fnameL2", fnameL2);
        return coaceGroupMapper.selectCoaceGroupByInfo(map);
    }
}
